* Setting the working directory
* Change this to your working directory

cd "/Users/david.rueda/Dropbox/David's Documents/Research/Redistribution preferences/JoP R&R/analysis/"

* Starting a log file
log using main.log, replace


* Preparing data: this file takes data from the ESS files, drops countries not in the analysis, recodes a number of variables for analysis,
* and saves the data in a working file (rueda.dta)

do preanalysis

* Producing Figure 3 in the paper (redistribution preferences of poor, mean, rich)

do graph01

* Creating macro foreign population variable from OECD International migration database
* And producing Figure 4 in the paper (foreign-born population)

do graph02

* Producing Table 1 (summary of redistribution preferences) and Table 2 (determinants of redistribution preferences)
* Producing predicted probabilities for Figures 5 and 6, the figures,
* and average marginal effects of foreign population for Table 3

do table01

* do graph03

* Producing robustness tests in Table 4

do robust

* Producing analysis of voting left and voting populist right

do left 

log close
exit
